package leetcode.editor.cn.q1xx

class Q125 {
    fun isPalindrome(s: String): Boolean {
        if (s.isEmpty()) return true
        var start = 0
        var end = s.lastIndex
        while (start < end) {
            if (!s[start].isLetterOrDigit()) {
                start++
                continue
            }
            if (!s[end].isLetterOrDigit()) {
                end--
                continue
            }
            if (s[start].toLowerCase() != s[end].toLowerCase())
                return false
            start++
            end--
        }
        return true
    }
}